﻿using BaseFramework;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace LiteFramework.Model
{
    /// <summary>
    /// 用户权限项
    /// </summary>
    [Serializable]
    [ComVisible(true)]
    [Entity("SYS_Right", Where = "Visible=1")]
    public sealed class Task : PersistentEntity<Task>
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        private Task()
        {
            this.Id = Guid.Empty.ToString();
            this.Code = String.Empty;
        }

        #region Properties

        /// <summary>
        /// Id
        /// </summary>
        [PrimaryKey("ID", UnsavedValue = "00000000-0000-0000-0000-000000000000")]
        [DisplayName("主键")]
        public string Id
        {
            get { return this.GetValue<string>("ID"); }
            private set { this.SetValue("ID", value); }
        }

        /// <summary>
        /// 分组名
        /// </summary>
        [Property("Group", NotNull = true)]
        [DisplayName("分组名")]
        public string Group
        {
            get { return this.GetValue("Group", null); }
            private set { this.SetValue("Group", value); }
        }

        /// <summary>
        /// 代码
        /// </summary>
        [Property("Code", NotNull = true, Insert = false, Update = false)]
        [DisplayName("代码")]
        public string Code
        {
            get { return this.GetValue("Code", null); }
            private set { this.SetValue("Code", value); }
        }

        /// <summary>
        /// 名称
        /// </summary>
        [Property("Name", NotNull = true)]
        [DisplayName("名称")]
        public string Name
        {
            get { return this.GetValue("Name", null); }
            private set { this.SetValue("Name", value); }
        }

        /// <summary>
        /// 顺序
        /// </summary>
        [Property("Seq")]
        [DisplayName("序号")]
        public int? Seq
        {
            get { return this.GetValue<int?>("Seq"); }
            private set { this.SetValue("Seq", value); }
        }

        /// <summary>
        /// 二级顺序
        /// </summary>
        [Property("SubSeq")]
        [DisplayName("二级序号")]
        public int? SubSeq
        {
            get { return this.GetValue<int?>("SubSeq"); }
            private set { this.SetValue("SubSeq", value); }
        }

        /// <summary>
        /// 备注
        /// </summary>
        [Property("Description")]
        [DisplayName("备注")]
        public string Description
        {
            get { return this.GetValue("Description", null); }
            private set { this.SetValue("Description", value); }
        }

        #endregion

        /// <summary>
        /// 
        /// </summary>
        public override string ToString()
        {
            return (!String.IsNullOrEmpty(this.Name) ? this.Name : this.Code);
        }
    }
}